<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>编辑轮播广告</title>
<link href="${base}/resources/admin/css/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${base}/resources/admin/js/jquery.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/jquery.validate.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/common.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/input.js"></script>
	<script type="text/javascript">
        function getCtxPath() {
            return "${ctxPath}";
        }
	</script>
	<script type="text/javascript" src="${base}/resources/admin/js/input.js"></script>
	<script type="text/javascript" charset="utf-8" src="${base}/resources/admin/neditor/neditor.config.js"></script>
	<script type="text/javascript" charset="utf-8" src="${base}/resources/admin/neditor/neditor.all.min.js"> </script>
	<script type="text/javascript" charset="utf-8" src="${base}/resources/admin/neditor/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript">

        var _upeditor;
        $().ready(function() {

            var $inputForm = $("#inputForm");

            [@flash_message /]
            _upeditor = UE.getEditor('upload_ue');
            _upeditor.ready(function(){
                _upeditor.hide();
                _upeditor.addListener('beforeInsertImage',function(t,arg){
                    $('#img_url').val(arg[0].src);
                    $('#img_preview').attr('src',arg[0].src);
                });
            });

            // 表单验证
            $inputForm.validate({
                rules: {
                    "banner.title": "required",
                    "banner.status" : "required",
                    "banner.img_url": "required",
                    "banner.url": "required",
                    "banner.orders": "digits"
                }
            });

        });

        function browserImg() {
            _upeditor.getDialog("insertimage").open();
        }

	</script>
	<style type="text/css">
		table.input td {
			line-height: 15px;
			padding: 5px;
			color: #666666;
			border-bottom: 1px solid #dde9f5;
		}
	</style>

</head>
<body>
	<div class="path">
		<a href="${base}/admin/index">${message("admin.path.index")}</a> &raquo; 编辑轮播图
	</div>
	<form id="inputForm" action="update" method="post">
		<input type="hidden" name="banner.id" value="${banner.id}"/>
        <table class="input">
            <tr>
                <th>
                    图片预览:
                </th>
                <td>
                    <img id="img_preview" src="${banner.img_url}" width="500" height="200" alt="图片预览"/>
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField">*</span>轮播图:
                </th>
                <td>

                    <script type="text/plain" id="upload_ue"></script>
                    <input id ="img_url" type="text" name="banner.img_url" value="${banner.img_url}" readonly = "true" class="text" maxlength="200" />
                    <input id="btn_browser" type="button" class="button" value="选择图片" onclick="browserImg()" />
                    <span class="tips">"建议图片宽度:500px，高度:200px"</span>
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField">*</span>标题:
                </th>
                <td>
                    <input type="text" name="banner.title" value="${banner.title}" class="text" maxlength="200" />
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField">*</span>URL:
                </th>
                <td>
                    <input type="text" name="banner.url" value="${banner.url}" class="text" maxlength="200" />
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField">*</span>状态:
                </th>
                <td>
                    <select name="banner.status">
                        <option value="OFFLINE" [#if banner.status == 'OFFLINE'] selected = "selected" [/#if] >下线</option>
                        <option value="ONLINE" [#if banner.status == 'ONLINE'] selected = "selected" [/#if]>上线</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th>
                    排序:
                </th>
                <td>
                    <input type="text" name="banner.orders" value="${banner.orders}" title="按数字从大到小排序" class="text" maxlength="9" />
                    <span class="tips">"按数字从大到小排序"</span>
                </td>

            </tr>
            <tr>
                <th>
                    &nbsp;
                </th>
                <td>
                    <input type="submit" class="button" value="${message("admin.common.submit")}" />
                    <input type="button" id="backButton" class="button" value="${message("admin.common.back")}" />
                </td>
            </tr>
        </table>
	</form>
</body>
</html>